import 'package:architecture/os_size.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'undohistory_controller.dart';

class UndoHistoryPage extends StatelessWidget {
  final UndoHistoryController _undoController = UndoHistoryController();

  @override
  Widget build(BuildContext context) {
    return GetBuilder<HistoryController>(
        init: HistoryController(),
        builder: (controller) {
          return Scaffold(
            appBar: AppBar(title: Text('UndoHistory')),
            body: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Row(
                  children: [
                    IconButton(
                        onPressed: () {
                          _undoController.undo();
                        },
                        icon: Icon(Icons.undo)),
                    IconButton(
                        onPressed: () {
                          _undoController.redo();
                        },
                        icon: Icon(Icons.redo))
                  ],
                ),
                _buildInputArea()
              ],
            ),
          );
        });
  }

  _buildInputArea() {
    return Container(
        width: windowWidth * 0.5,
        height: windowHeight * 0.6,
        margin: EdgeInsets.symmetric(horizontal: 10),
        child: TextField(
          undoController: _undoController,
          expands: true,
          maxLines: null,
          minLines: null,
          textAlignVertical: TextAlignVertical.top,
          decoration: InputDecoration(
            filled: true,
            fillColor: Colors.transparent,
            hoverColor: Colors.transparent,
            border: const OutlineInputBorder(),
          ),
        ));
  }
}
